<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="/views/global/taglibs.jsp" %>
<style type="text/css">
	.main-md DIV.form-group{border-bottom: 1px dashed #ddd;}
	.grid .g-u {
	   display:inline-block
	}
	.maincontent{background: #e4e7ea;} 
	.text-muted {
	    text-transform: uppercase;
    }
    .results-list .media {
    border-bottom: 1px solid #eee;
	}
	.results-list .media-object {
	    width: 125px;
	    margin-right: 10px;
	}
	.results-list .filename {
	    margin: 0;
	    font-size: 16px;
	}
	.results-list .media-body {
	    line-height: 18px;
	}
</style>
<div class="maincontent">      
	<div class="row">
		
		<div class="col-sm-11 col-md-12">
			<div class="panel panel-default">
				<div class="panel-heading">
					<div class="panel-title">配置搜索</div>
				</div>
				<div class="panel-body">
				      <form id="itemForm" class="form-horizontal" role="form" name="itemForm" action="admin/displayPicConfigList" method="post">
						<input type="hidden" name="toAddType" value="${toAddType }"/>
						<input type="hidden" name="toDisType" value="${toDisType }"/>
						<div class="form-group">
							<label class="col-sm-1 control-label" for="disType">场景: </label>
							<div class="col-sm-3">
								<select id="disType" name="disType" class="form-control" data-placeholder="选择一个场景">
				                  <option value=""></option>
				                  <c:forEach var="item" items="${distTypes}">
			  						<option value="${item.dictValue }" <c:if test="${item.dictValue eq queryParamVo.disType }"> selected</c:if>>${item.dictName }</option>
					  			  </c:forEach>
						         </select>
							</div>
							<label class="col-sm-1 control-label" for="title">标题: </label>
							<div class="col-sm-3">
								<input class="form-control" name="title" id="title" value="${queryParamVo.title }"/>
							</div>
							<div class="col-sm-2">
								<button type="submit" class="btn btn-primary">搜 索</button>
							</div>
						</div>
						</form>
				</div>
			</div>
            <div class="panel panel-default">
                <div class="panel-heading">
                    <a href="admin/displayPicConfigList/toAdd?toAddType=${toAddType }"><button type="button" class="btn btn-default" id="addDisplayPicConfig">添加</button></a>
                    <div class="pull-right">
                     <pagination:pagenav pageInfo="${pageInfo }" url="${actionPath }" formName="itemForm" showTotalSize="true"></pagination:pagenav>
                    </div>
                </div><!-- panel-heading -->
                <div class="panel-body">
                    <div class="results-list">
                     <div class="row">
                        <c:forEach var="entry" items="${entryList }">
                         <div class="media">
                           <div class="col-md-1">
                              <input type="checkbox" name="isDisplay" id="isDisplay" <c:if test="${entry.status eq 1 }"> checked</c:if> onclick="check(this,'${entry.id }')"/>
                           </div>
                           <div class="col-md-10">
                           	 <div class="row">
                           	 	<div class="col-xs-5">
                           	 		<img alt="" src="${fileServerBasePath }download/${entry.fileId  }" width="300" height="250">
                           	 	</div>
                           	 	<div class="col-xs-7">
                           	 		<div class="text-muted">场景: ${entry.disType }</div>
		                            <div class="text-muted">标题: ${entry.title }</div>
		                            <div class="text-muted">描述: ${entry.comments }</div>
                           	 	</div>
                           	 </div>
                           </div>
                           <div class="col-md-1">
                            <a href="admin/displayPicConfigList/toAdd?id=${entry.id }&toAddType=${toAddType }">EDIT</a><br/>
							<a id="displayConfigRemove" onclick="deleteNode(this,${entry.id})" class="pull-left">DELETE</a>
                           </div>
                         </div>
                        </c:forEach>
                      </div>
                    </div><!-- results-list -->
                </div><!-- panel-body -->
            </div><!-- panel -->
     	</div><!-- col-sm-8 -->
     	
	</div>
</div>

<script type="text/javascript">
$(document).ready(function(){
	<c:if test="${empty message }">$(".alert").hide();</c:if>
	
});

function check(obj,id){
	var status=0;
	if(obj.checked){
		status=1;
	}
	$("#itemForm").goAjax({semantic: false, checkLogin: false,
		url: "admin/displayPicConfigList/doCheck",
		data:{id: id,status:status},
		success: function(jsonData) {
		}
	});
}

function deleteNode(target, objId){
	$("#itemForm").goAjax({semantic: false, checkLogin: false,
		url: "admin/displayPicConfigList/doRemove",
		data:{id: objId},
		success: function(jsonData) {
			location.reload();
		}
	});
}

//图片按比例缩放
var flag=false;
function drawImage(ImgD,iwidth,iheight){
	//参数(图片,允许的宽度,允许的高度)
	var image=new Image();
	image.src=ImgD.src;
	if(image.width>0 && image.height>0){
	flag=true;
	if(image.width/image.height>= iwidth/iheight){
	if(image.width>iwidth){ 
	ImgD.width=iwidth;
	ImgD.height=(image.height*iwidth)/image.width;
	}else{
	ImgD.width=image.width; 
	ImgD.height=image.height;
	}
	ImgD.alt=image.width+"×"+image.height;
	}
	else{
	if(image.height>iheight){ 
	ImgD.height=iheight;
	ImgD.width=(image.width*iheight)/image.height; 
	}else{
	ImgD.width=image.width; 
	ImgD.height=image.height;
	}
	ImgD.alt=image.width+"×"+image.height;
	}
	}
} 


</script>
